﻿using SqlSugar;

namespace JunionRobotTaskManager.Models
{
    public static class ApiResultHelper
    {
        //成功后返回的数据
        public static ApiResult Success(dynamic data)
        {
            return new ApiResult
            {
                Code = 200,
                Data = data,
                Msg = "操作成功",
                Total = 0
            };
        }
        public static ApiResult Success(dynamic data, RefAsync<int> total)
        {
            return new ApiResult
            {
                Code = 200,
                Data = data,
                Msg = "操作成功",
                Total = total
            };
        }
        public static ApiResult Error(string msg)
        {
            return new ApiResult
            {
                Code = 500,
                Data = null,
                Msg = msg,
                Total = 0
            };
        }
        public static ApiResult Error(string msg, int code)
        {
            return new ApiResult
            {
                Code = code,
                Data = null,
                Msg = msg,
                Total = 0
            };
        }


    }

    public class ApiResult
    {
        public int Code { get; set; }
        public string Msg { get; set; }
        public int Total { get; set; }
        public dynamic Data { get; set; }
    }

    public class ResponseResult
    {
        public int Code { get; set; }
        public string Message { get; set; }
        public int Result { get; set; }
        public string Data { get; set; }
    }
}
